package com.share.common.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author Administrator
 * @data 2019/6/9
 */
@Data
@ApiModel("分页page")
public class Page<T> extends PageReq implements Serializable {
    @ApiModelProperty("总记录数")
    private long pageTotal;

    @ApiModelProperty("分页数据")
    private List<T> pageList;

    public Page(List<T> list, long pageTotal) {
        this.pageList = list;
        this.pageTotal = pageTotal;
    }

    public Page() {
    }

    /**
     * @param list      list数据
     * @param pageTotal 总记录数
     * @param pageNum   第几页
     */
    public Page(List<T> list, long pageTotal, int pageNum) {
        this.pageList = list;
        this.pageTotal = pageTotal;
        this.pageNum = pageNum;
    }

    public Page(List<T> list, long pageTotal, int pageNum, int pageSize) {
        this.pageTotal = pageTotal;
        this.pageList = list;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public Page(List<T> list, long pageTotal, int pageNum, int pageSize, String orderBys) {
        this.pageTotal = pageTotal;
        this.pageList = list;
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.orderBys = orderBys;
    }

    public Page(List<T> list, long pageTotal, PageReq pageReq) {
        this.pageList = list;
        this.pageTotal = pageTotal;
        this.pageNum = pageReq.getPageNum();
        this.pageSize = pageReq.getPageSize();
        this.orderBys = pageReq.getOrderBys();
    }
}
